﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using KPI.OrganizationDomain.Service;
using KPI.OrganizationDomain.Model.Entity;
using System.Data;

namespace KPI.WebApp.Organization
{
    public partial class CreateDepartment : System.Web.UI.Page
    {
       
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                OrganizationService employeeService = new OrganizationService();
                DataTable strDirector = employeeService.SelectEmployeeDirector();

                this.DropListDirector.DataSource = strDirector;
                this.DropListDirector.DataValueField = "EmployeeLevelID";
                this.DropListDirector.DataTextField = "FirstName";
                DropListDirector.DataBind();
            }
           
        }

        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            if (txtBxName.Text.Trim() != null)
            {
                Department departmentdDto = new Department();
                departmentdDto.Name = txtBxName.Text.ToString();
                departmentdDto.Description = txtBxDescription.Text.ToString();

                OrganizationService organizationService = new OrganizationService();
                organizationService.CreateDepartment(departmentdDto);
            }
        }
    }
}